﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using RoadTeam.Model;
using RoadTeam.Enums;
using RoadTeam.Pub;

namespace RoadTeam.BLL
{
    public class CsListItemBLL : BllBase
    {

        public DataTable GetCsListItemData()
        {

          //获取乐天数据库中的项目名称
         DataTable dt=RoadTeam.SysInterface.FactoryClass.CreateCsListItem().GetAllCsListItemFromRoadTeamSystem();
         DataTable dt_ListItem = GetEmptyCsListItemData();
         DataRow dr_listItem;
         foreach (DataRow drTemp in dt.Rows)
         {
             dr_listItem = dt_ListItem.NewRow();
             dr_listItem["ListItemIdentifier"] = CreateIdentifier.GetIdentifier();
             dr_listItem["ListItemName"] = drTemp[1];
             dr_listItem["ListItemContent"] = drTemp[2];
             dr_listItem["ListItemRemark"] = drTemp[3];
             drTemp[4] = dr_listItem["ListItemIdentifier"];
             dt_ListItem.Rows.Add(dr_listItem);
         }
         CsListItem.InsertDatatable(dt_ListItem,GlobalConfig.ConnectionString);
         RoadTeam.SysInterface.FactoryClass.CreateCsListItem().UpdateCsListItemToRoadTeamSystem(dt);
            //同步服务器中的类型
         SqlWhere where = new SqlWhere();
         return  CsListItem.Select(where, GlobalConfig.ConnectionString);
        }

        public DataTable GetEmptyCsListItemData()
        {
            SqlWhere where = new SqlWhere();
            where.Info = new CsListItem() { ListItemIdentifier="-1" };
           return  CsListItem.Select(where, GlobalConfig.ConnectionString);
        }
    }
}
